﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;

namespace Jenkins.App01.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class ValuesController : ControllerBase
    {
        public ValuesController(IHostEnvironment env)
        {
            this.env = env;
        }

        private IHostEnvironment env;
        private List<string> choices => new List<string>
            {"Apple", "Carrot", "Pear", "Pineapple", "Banana", "Peach", "Coconut"};

        [HttpGet]
        public IEnumerable<String> Get()
        {
            var rng = new Random().Next(7);
            var ip =  System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());
            var ipstrs = ip.Select(x => x.ToString());
            //var ip = System.Net.IPAddress.;
            return  new List<string>(){"03",env.EnvironmentName, ipstrs.Aggregate((x,y) => x + "," + y ),choices[rng]};
        }
    }
}
